import 'package:flutter/material.dart';
import '../model/details.dart';
import '../service/service_method.dart';
import 'dart:convert';

class DetailsInfoProvide with ChangeNotifier{
  DetailsModel goodsinfo = null;
  var evalistsData = null;
  bool isLeft = true;
  bool isRight = false;

  //详情和评论的切换
  changeLeftAndRight(String change){
    if (change == 'left') {
      isLeft = true;
      isRight = false;
    }else{
      isLeft = false;
      isRight = true;
    }
    notifyListeners();
  }



  //从后台获取商品数据

  getGoodsInfo(String id) async{
    print('ajsdlks==============================================');
    var formData = {
      'id':id
    };
    var formDats = {
       'id':id,
      'type':4
    };
    await DioUtil.request("getGoodDetail",formData: formData).then((val){
      var responseData = val;
      print(responseData);
      goodsinfo = DetailsModel.fromJson(responseData);
      print(goodsinfo);
      print('-------------------================================-------------');
      notifyListeners();
    });
    await DioUtil.request("getGoodEvaList",formData: formDats).then((val){
      var evalists = val;
      evalistsData = evalists;
      // print(evalistsData);
      notifyListeners();
    });
  }



}